package com.fengcbo.mysql.sharding;


import java.time.LocalDateTime;

import javax.annotation.Resource;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import com.fengcbo.mysql.sharding.entity.Order;
import com.fengcbo.mysql.sharding.repository.OrderRepository;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Resource
    private OrderRepository orderRepository;

    @Bean
    public ApplicationRunner applicationRunner() {
        return args -> {

            for (int i = 10; i < 20; i++) {
                Order order = new Order();
                order.setId((long) (i + 1));
                order.setTitle("hello"+i);
                orderRepository.save(order);
            }
        };
    }

}
